* This do file runs child outcomes (Bayley-4) impact analysis for the FEIE study


cd "...." /// set path
use "...dta", clear /// set path


*OUTLIERS
*expressive language H-0279-C-70207 H-0288-C-73355 H-0455-C-77043
*receptive language                                H-0455-C-77043  H-0428-C-70328
* cognitive 		                H-0288-C-73355 H-0455-C-77043

**The analysis drops H-0279-C-70207 H-0288-C-73355 H-0455-C-77043  H-0428-C-70328

drop if hhid_final=="H-0279-C-70207"| hhid_final=="H-0288-C-73355"|hhid_final== "H-0455-C-77043" ///
|hhid_final== "H-0428-C-70328"| hhid_final=="H-0189-C-76576"|hhid_final=="H-0402-C-71403"| ///
hhid_final=="H-0179-C-75382"| hhid_final=="H-0376-C-77518"|hhid_final=="H-0179-C-75382"| ///
hhid_final=="H-0177-C-69709"
* 9 of 10 dropped.

/* the dataset has these variables generated
gen f_bay_tot_child_agemo=f_bay_tot_child_ageday/30.416
encode f_bay_enumid, gen(bay_enumid)
*/

/* which interactions should we keep in the models?

 foreach x of varlist f_bay_cog_ss f_bay_rcp_ss f_bay_exp_ss f_bay_lang_ss  ///
{ 
mixed `x' tx camp ///
_1_f_age _1_m_age i.fb_q1_edu i.fb_grade i.fb_q4_edu ///
_1_child_fem f_bay_tot_child_agemo ///
i._1_mb_q1_hunger i._1_mb_q2_hunger _1_mb_q4_pregnant _1_mb_child_count ///
i._1_mb_q2_fin _1_hh_res _1_hh_qua ///
camp#c._1_f_age camp#c._1_m_age camp#i.fb_q1_edu camp#i.fb_grade camp#i.fb_q4_edu ///
camp#_1_child_fem camp#c.f_bay_tot_child_agemo ///
camp#i._1_mb_q1_hunger camp#i._1_mb_q2_hunger camp#_1_mb_q4_pregnant camp#c._1_mb_child_count ///
camp#i._1_mb_q2_fin camp#c._1_hh_res camp#c._1_hh_qua ///
|| mvid: ||clu2:


testparm camp#c._1_f_age
testparm camp#c._1_m_age
testparm camp#i.fb_q1_edu 
testparm camp#i.fb_grade 
testparm camp#i.fb_q4_edu
testparm camp#_1_child_fem 
testparm camp#c.f_bay_tot_child_agemo
testparm camp#_1_mb_q1_hunger 
testparm camp#_1_mb_q2_hunger 
testparm camp#_1_mb_q4_pregnant 
testparm camp#c._1_mb_child_count 
testparm camp#_1_mb_q2_fin 
testparm camp#c._1_hh_res 
testparm camp#c._1_hh_qua 
}

*/

*** BAYLEY TREATMENT EFFECTS WITH ENUM CONTROLS

foreach x of varlist f_bay_cog_ss f_bay_rcp_ss f_bay_exp_ss f_bay_lang_ss  ///
{
mixed `x' tx camp ///
_1_f_age _1_m_age i.fb_q1_edu i.fb_grade i.fb_q4_edu ///
_1_child_fem f_bay_tot_child_agemo ///
i._1_mb_q1_hunger i._1_mb_q2_hunger _1_mb_q4_pregnant _1_mb_child_count ///
i._1_mb_q2_fin _1_hh_res _1_hh_qua ///
camp#c._1_f_age camp#c._1_m_age camp#i.fb_q1_edu camp#i.fb_grade camp#i.fb_q4_edu ///
camp#_1_child_fem camp#c.f_bay_tot_child_agemo ///
camp#i._1_mb_q1_hunger camp#i._1_mb_q2_hunger camp#_1_mb_q4_pregnant camp#c._1_mb_child_count ///
camp#i._1_mb_q2_fin camp#c._1_hh_res camp#c._1_hh_qua ///
i.bay_enumid ///
|| mvid: ||clu2:
testparm i.bay_enumid

*HOST
mixed `x' i.tx##camp ///
_1_f_age _1_m_age i.fb_q1_edu i.fb_grade i.fb_q4_edu ///
_1_child_fem f_bay_tot_child_agemo ///
i._1_mb_q1_hunger i._1_mb_q2_hunger _1_mb_q4_pregnant _1_mb_child_count ///
i._1_mb_q2_fin _1_hh_res _1_hh_qua ///
camp#c._1_f_age camp#c._1_m_age camp#i.fb_q1_edu camp#i.fb_grade camp#i.fb_q4_edu ///
camp#_1_child_fem camp#c.f_bay_tot_child_agemo ///
camp#i._1_mb_q1_hunger camp#i._1_mb_q2_hunger camp#_1_mb_q4_pregnant camp#c._1_mb_child_count ///
camp#i._1_mb_q2_fin camp#c._1_hh_res camp#c._1_hh_qua ///
i.bay_enumid ///
|| mvid: ||clu2:
testparm i.bay_enumid

 *CAMP

mixed `x' tx##host ///
_1_f_age _1_m_age i.fb_q1_edu i.fb_grade i.fb_q4_edu ///
_1_child_fem f_bay_tot_child_agemo ///
i._1_mb_q1_hunger i._1_mb_q2_hunger _1_mb_q4_pregnant _1_mb_child_count ///
i._1_mb_q2_fin _1_hh_res _1_hh_qua ///
host#c._1_f_age host#c._1_m_age host#i.fb_q1_edu host#i.fb_grade host#i.fb_q4_edu ///
host#_1_child_fem host#c.f_bay_tot_child_agemo ///
host#i._1_mb_q1_hunger host#i._1_mb_q2_hunger host#_1_mb_q4_pregnant host#c._1_mb_child_count ///
host#i._1_mb_q2_fin host#c._1_hh_res host#c._1_hh_qua ///
i.bay_enumid ///
|| mvid: ||clu2:
testparm i.bay_enumid

}



foreach x of varlist f_bay_cog_ss f_bay_rcp_ss f_bay_exp_ss f_bay_lang_ss  ///
{
sum `x'
sum `x' if camp==0
sum `x' if camp==1
}

*** FOR CREDI OUTCOMES, SEE .Rmd files.
